Skip to content

Conversation

@david-zlai
Copy link
Contributor

@david-zlai david-zlai commented May 16, 2025

pass leftSpec

use partition column of left for scanDf

Add integration test for the notds case

scalafmt

Summary

Duplicate of #780 without the nasty merge conflicts

Checklist

  • Added Unit Tests
  • Covered by existing CI
  • Integration tested
  • Documentation update

Summary by CodeRabbit

  • New Features

    • Introduced new data sources and aggregations for purchase and checkout events with additional partitioning, enabling enhanced reporting and analysis for datasets suffixed with "_notds".
    • Added new join configurations to support the newly introduced data sources in both test and development environments.
  • Chores

    • Updated automation scripts to handle table cleanup and backfill operations for the new "_notds" datasets.
  • Style

    • Improved code readability and log formatting in several components without affecting functionality.

pass leftSpec

use partition column of left for scanDf

Add integration test for the notds case

scalafmt
@coderabbitai
Copy link
Contributor

coderabbitai bot commented May 16, 2025

Walkthrough

New event sources and group-by configurations using partitioned tables were added for purchases and training set joins in the canary test suite. Shell scripts were updated to handle the new datasets, and Scala code was refactored to clarify partition column usage and streamline log formatting. No public API signatures were changed.

Changes

File(s) Change Summary
api/python/test/canary/group_bys/gcp/purchases.py Added source_notds for partitioned purchases; introduced v1_test_notds and v1_dev_notds GroupBy configs.
api/python/test/canary/joins/gcp/training_set.py Switched to module import for purchases; added source_notds and two new Join configs for _notds datasets.
scripts/distribution/run_gcp_quickstart.sh Added table cleanup and backfill runs for new _notds datasets in both canary and dev environments.
spark/src/main/scala/ai/chronon/spark/JoinUtils.scala Refactored to use local partition column variable and simplified log formatting and lambda expressions.
spark/src/main/scala/ai/chronon/spark/batch/StagingQuery.scala Simplified log message formatting in computeStagingQuery.
spark/src/main/scala/ai/chronon/spark/catalog/TableUtils.scala Introduced effectivePartColumn for consistent partition column usage in partition retrieval and logging.
spark/src/test/scala/ai/chronon/spark/test/TableUtilsTest.scala Reordered import statements for clarity; no logic changes.

Sequence Diagram(s)

sequenceDiagram
    participant Script
    participant BQ
    participant Zipline
    participant Purchases
    participant TrainingSet

    Script->>BQ: Delete old _notds tables
    Script->>Zipline: Run backfill for purchases_v1_test_notds
    Zipline->>Purchases: Aggregate purchases_notds by user_id
    Script->>Zipline: Run backfill for training_set_v1_test_notds
    Zipline->>TrainingSet: Join checkouts_notds with purchases_notds group-by
Loading

Suggested reviewers

  • nikhil-zlai
  • varant-zlai
  • piyush-zlai

Poem

New sources bloom, partitioned and neat,
With joins and group-bys that never skip a beat.
Scripts sweep clean, Scala logs now shine,
Imports in order, everything in line.
Data flows onward, in columns anew—
Here’s to the changes, and the devs who pursue! 🚀

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
Learn more here.


Note

⚡️ Faster reviews with caching

CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.
Enjoy the performance boost—your workflow just got faster.


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@david-zlai david-zlai mentioned this pull request May 16, 2025
4 tasks
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
scripts/distribution/run_gcp_quickstart.sh (1)

164-164: Extra blank line.

Minor formatting issue.

-
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between 4e7b865 and 18da9a9.

📒 Files selected for processing (7)
  • api/python/test/canary/group_bys/gcp/purchases.py (1 hunks)
  • api/python/test/canary/joins/gcp/training_set.py (2 hunks)
  • scripts/distribution/run_gcp_quickstart.sh (2 hunks)
  • spark/src/main/scala/ai/chronon/spark/JoinUtils.scala (4 hunks)
  • spark/src/main/scala/ai/chronon/spark/batch/StagingQuery.scala (1 hunks)
  • spark/src/main/scala/ai/chronon/spark/catalog/TableUtils.scala (1 hunks)
  • spark/src/test/scala/ai/chronon/spark/test/TableUtilsTest.scala (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (3)
spark/src/main/scala/ai/chronon/spark/batch/StagingQuery.scala (1)
spark/src/main/scala/ai/chronon/spark/Extensions.scala (1)
  • pretty (40-52)
spark/src/main/scala/ai/chronon/spark/catalog/TableUtils.scala (2)
cloud_gcp/src/main/scala/ai/chronon/integrations/cloud_gcp/BigQueryNative.scala (2)
  • partitions (186-263)
  • primaryPartitions (139-184)
spark/src/main/scala/ai/chronon/spark/catalog/Format.scala (1)
  • primaryPartitions (49-72)
api/python/test/canary/joins/gcp/training_set.py (3)
api/src/main/scala/ai/chronon/api/Builders.scala (1)
  • Source (106-140)
api/python/ai/chronon/source.py (1)
  • EventSource (8-35)
api/python/ai/chronon/query.py (1)
  • selects (103-126)
⏰ Context from checks skipped due to timeout of 90000ms (29)
  • GitHub Check: service_tests
  • GitHub Check: streaming_tests
  • GitHub Check: service_commons_tests
  • GitHub Check: streaming_tests
  • GitHub Check: service_tests
  • GitHub Check: online_tests
  • GitHub Check: spark_tests
  • GitHub Check: online_tests
  • GitHub Check: groupby_tests
  • GitHub Check: join_tests
  • GitHub Check: flink_tests
  • GitHub Check: flink_tests
  • GitHub Check: analyzer_tests
  • GitHub Check: batch_tests
  • GitHub Check: cloud_gcp_tests
  • GitHub Check: cloud_gcp_tests
  • GitHub Check: spark_tests
  • GitHub Check: api_tests
  • GitHub Check: cloud_aws_tests
  • GitHub Check: fetcher_tests
  • GitHub Check: cloud_aws_tests
  • GitHub Check: groupby_tests
  • GitHub Check: scala_compile_fmt_fix
  • GitHub Check: api_tests
  • GitHub Check: batch_tests
  • GitHub Check: aggregator_tests
  • GitHub Check: analyzer_tests
  • GitHub Check: python_tests
  • GitHub Check: aggregator_tests
🔇 Additional comments (19)
spark/src/test/scala/ai/chronon/spark/test/TableUtilsTest.scala (1)

24-24: Import reordering looks good.

This is just a reordering of imports and doesn't affect functionality.

spark/src/main/scala/ai/chronon/spark/batch/StagingQuery.scala (1)

63-63: Cleaner log formatting.

Simplified log formatting by using a concise lambda expression.

spark/src/main/scala/ai/chronon/spark/catalog/TableUtils.scala (2)

133-134: Good variable introduction for partition column resolution.

Introducing effectivePartColumn improves clarity and ensures the correct partition column is used consistently.


139-142: Consistently using the resolved partition column.

Using effectivePartColumn in both logging and in the primaryPartitions call ensures consistent partition column handling.

scripts/distribution/run_gcp_quickstart.sh (4)

75-76: Added cleanup for new _notds tables.

Adding cleanup for tables with non-default partition columns in canary environment.


83-84: Added cleanup for new _notds tables in dev environment.

Consistent with the changes for canary environment above.


156-157: Added backfill for _notds tables in canary environment.

This supports the non-standard partition column tables introduced in the PR.


160-160: Added backfill for _notds tables in dev environment.

Ensures consistent handling in both environments.

spark/src/main/scala/ai/chronon/spark/JoinUtils.scala (5)

86-86: Improved partition column handling.

This change explicitly extracts the partition column from the left specification, enabling correct partition column usage.


90-90: Fixed partition column reference.

Now properly using the partition column from the left specification instead of default partition column from tableUtils.


176-176: Corrected PartitionRange construction.

Using leftSpec instead of tableUtils.partitionSpec ensures the partition range is built with the correct partition specification.


328-329: Improved logging readability.

Consolidated logging into a cleaner single-line format with string concatenation.


496-496: Simplified code structure.

Removed unnecessary braces and line breaks for better readability.

api/python/test/canary/joins/gcp/training_set.py (4)

1-1: Updated import to access all purchases module objects.

Changed to import the entire module to reference the new notds group-by configurations.


26-26: Updated references with module qualification.

Now correctly referencing GroupBy objects through the purchases module.

Also applies to: 33-33


37-48: Added new source with custom partition column.

Created a new source_notds that uses "notds" as partition column to support non-date-string partitioning.


50-62: Added Join configurations for notds partitioned data.

New Join objects that work with the custom partition column, completing the integration test coverage.

api/python/test/canary/group_bys/gcp/purchases.py (2)

138-148: Added source with custom partition column.

Created a source_notds with partition_column="notds" to test non-date-string partitioning.


150-202: Added GroupBy configurations for notds partitioned data.

Created test and dev versions of GroupBy configurations using the custom partition column source.

@david-zlai david-zlai changed the title fix the partition column Fix join backfills when a new partition column is set for the Query May 16, 2025
if (!tableReachable(tableName)) return List.empty[String]
val rangeWheres = andPredicates(partitionRange.map(_.whereClauses).getOrElse(Seq.empty))

val effectivePartColumn = tablePartitionSpec.map(_.column).getOrElse(partitionColumnName)
Copy link
Collaborator

@tchow-zlai tchow-zlai May 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we might want to prioritize the spec in the range, then the table spec, then the default spec?


logger.info(s"Attempting to fill join partition range: $leftStart to $leftEnd")
PartitionRange(leftStart, leftEnd)(tableUtils.partitionSpec)
PartitionRange(leftStart, leftEnd)(leftSpec)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we might want to default to the tableUtils.partitionSpec if there's no leftSpec?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that auto magically happens

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Implicit boy"

@david-zlai david-zlai merged commit 76f83d5 into main May 16, 2025
35 checks passed
@david-zlai david-zlai deleted the davidhan/tchow/fix-table-utils-2 branch May 16, 2025 04:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants